# flashlight
#
# IMPORTED targets
# ^^^^^^^^^^^^^^^^
#
# Configuration file for flashlight. Provides the following
# `IMPORTED` targets:
#
# ``flashlight::flashlight``
#   The complete flashlight library.
#
# The above targets can be linked with your build using ``target_link_library``.
# Example:
#
#   add_executable(myexecutable mySource.cpp)
#   target_link_library(myexecutable PRIVATE flashlight::flashlight)
#
# The above properly links flashlight with myexecutable. No call to
# ``target_include_directories`` is required.
#

# Configuration variables
# These variables are visible to downstream projects to express
# information about the configuration with which Flashlight was built
set(FL_BUILD_DISTRIBUTED "@FL_BUILD_DISTRIBUTED@")

# Dependencies
# If not building standalone, don't try to find upstream deps;
# many of these CMake modules aren't standard
if (@FL_BUILD_STANDALONE@)
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
  include(CMakeFindDependencyMacro)

  # Core dependencies
  find_dependency(Threads)
  if (@FL_USE_ARRAYFIRE@)
    find_dependency(ArrayFire 3.7.1)
  endif()
  if (@FL_USE_ONEDNN@)
    find_dependency(DNNL)
  endif()
  # remove when gcc >= 9 required
  find_dependency(Filesystem COMPONENTS Final Experimental)
  if (@FL_BUILD_DISTRIBUTED@)
    find_dependency(MPI)
  endif()
  # Backend-specific dependencies
  if (@FL_USE_CPU@)
    if (@FL_USE_ONEDNN@)
      find_dependency(DNNL)
    endif()
    if (@FL_BUILD_DISTRIBUTED@)
      find_dependency(Gloo)
    endif()
  endif()
  if (@FL_USE_CUDA@)
    if (@FL_USE_CUDNN@)
      find_dependency(CUDNN 7.1)
    endif()
    if (@FL_BUILD_DISTRIBUTED@)
      find_dependency(NCCL)
    endif()
  endif()
  # App dependencies
  if (@FL_BUILD_PKG_RUNTIME@)
    find_dependency(gflags)
    find_dependency(GLOG)
  endif()
  # Additional app-specific dependencies
  if (@FL_BUILD_PKG_SPEECH@)
    find_dependency(SndFile)
    # Audio feature components
    find_dependency(OpenMP)
    find_dependency(Threads)
    find_dependency(FFTW3)
    if (@FL_USE_MKL@)
      find_dependency(MKL)
    else()
      find_dependency(CBLAS)
    endif()
  endif()
  # Remove this dir from module path
  list(REMOVE_AT CMAKE_MODULE_PATH -1)
endif() # FL_BUILD_STANDALONE

################################################################################

@PACKAGE_INIT@

if(NOT TARGET flashlight::flashlight)
  if(EXISTS @PACKAGE_CMAKE_DIR@/flashlightTargets.cmake)
    include(@PACKAGE_CMAKE_DIR@/flashlightTargets.cmake)
  endif()
endif()

# Flashlight backend variables for downstream config use
set(FL_USE_CPU @FL_USE_CPU@)
set(FL_USE_CUDA @FL_USE_CUDA@)

if (@FL_USE_CUDA@)
  enable_language(CUDA)
endif()

# For legacy configurations
# Libraries
set(flashlight_LIBRARIES "")

# core
set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::flashlight)

# pkgs
if (@FL_BUILD_PKG_RUNTIME@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::fl_pkg_runtime)
endif()
if (@FL_BUILD_PKG_VISION@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::fl_pkg_vision)
endif()
if (@FL_BUILD_PKG_TEXT@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::fl_pkg_text)
endif()
if (@FL_BUILD_PKG_SPEECH@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::fl_pkg_speech)
endif()
if (@FL_BUILD_PKG_HALIDE@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::fl_pkg_halide)
endif()
# Include dirs
if (EXISTS @PACKAGE_INCLUDE_DIRS@)
  set(flashlight_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@)
endif()
set(flashlight_FOUND 1)
